

const yz = require('../comm/yz');
var moment = require("moment");
var math = require("mathjs");

exports.fmtContract = function (contract) {

    contract = yz.IsNullThen(contract, {});
    contract.name = yz.IsNullThen(contract.name, "");
    contract.code = yz.IsNullThen(contract.code, "");
    contract.createTime = yz.IsNullThen(contract.createTime, new Date());
    contract.statusId = yz.IsNullThen(contract.statusId, 0);
    contract.count = yz.IsNullThen(contract.count, {});
    contract.count.amount = yz.IsNullThen(contract.count.amount, 0);     //总额
    contract.count.reAmount = yz.IsNullThen(contract.count.reAmount, 0);   //已收款
    contract.customerOrderIdArray = yz.IsNullThen(contract.customerOrderIdArray, []);   //订单编号
    return contract
    // body...
};



exports.statusArray = function () {
    // body...
    return [
        {
            id: 0,
            name: "新创建"
        },
        {
            id: 100,
            name: "等待收款"
        },
        {
            id: 200,
            name: "部分已收"
        }, {
            id: 300,
            name: "已结款"
        }

    ]


};



exports.getStatusName = function (statusId) {
    // body...
    var statusName = ""
    this.statusArray().forEach(function (status) {
        if (status.id == statusId) {

            statusName = status.name
        }


    }, this);

    return statusName

};

